package cn.mxz.service.impl;

import cn.mxz.mapper.ShoppingCartMapper;
import cn.mxz.pojo.ShoppingCart;
import cn.mxz.service.ShoppingCartService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Autowired
    private ShoppingCartMapper shoppingCartMapper;
    @Override
    public List<ShoppingCart> getShoppingCartByUserId(String userid) {
        List<ShoppingCart> shoppingCarts = shoppingCartMapper.selectShoppingCart(userid);
        return shoppingCarts;
    }

    @Override
    public int addShoppingCart(ShoppingCart shoppingCart) {
        shoppingCart.setCartTime(new Date());
        int insert = shoppingCartMapper.insert(shoppingCart);
        return insert;
    }

    @Override
    public int deleteShoppingCart(String cart_id) {
        int i = shoppingCartMapper.deleteById(cart_id);
        return i;
    }
}
